{extend name='../../admin/view/table'}

{block name="button"}

<button data-modal='{:url("add")}' data-title="添加" class='layui-btn layui-btn-sm layui-btn-primary'>添加</button>

{/block}
{block name="content"}
<div class="think-box-shadow">
    {include file='merchant_cate/search'}
    <table id="RoleTable" data-url="{:request()->url()}" data-target-search="form.form-search"></table>
</div>
{/block}

{block name='script'}
<script>
    $(function () {
        // 初始化表格组件
        $('#RoleTable').layTable({
            even: true,
            skin : "line",
            limit : 15,
            size : 'lg',
            sort: {field: 'id', type: 'desc'},
            cols: [[
                // {checkbox: true, fixed: true},
                {field: 'id', title: '{:lang("ID")}', align: 'center', width: 100, sort: true,},
                {field: 'cate', title: '{:lang("分类")}', align: 'center',templet: function (d) {
                        return d.cate ? d.cate.cate_name : ''
                }},
               
                {field: 'title', title: '{:lang("商家")}', align: 'center'},
               
                {field: 'user_name', title: '{:lang("联系人")}', align: 'center'},
                {field: 'user_phone', title: '{:lang("联系方式")}', align: 'center'},
                {field: 'thumb', title: '{:lang("省市区")}', align: 'center', templet: function (d) {
                        return d.province + ' - ' + d.city + ' - ' + d.area
                }},
                {field: 'address', title: '{:lang("地址")}', align: 'center'},
                {field: 'status', title: '{:lang("状态")}', align: 'center', minWidth: 110, templet: '#StatusSwitchTpl'},
                {toolbar: '#toolbar', title: '{:lang("操作面板")}', align: 'center', minWidth: 210, fixed: 'right'},
            ]]
        });


    });

</script>
<!-- 数据状态切换模板 -->
<script type="text/html" id="StatusSwitchTpl">
   {{#  if(d.status == 0){ }}
         <span class="layui-badge layui-bg-gray">待审核</span>
  {{#  } }}
  {{#   if(d.status == 1){ }}
         '<span class="layui-badge layui-bg-green">已通过</span>';
   {{#   } }}
   {{#   if(d.status == 2){ }}
         '<span class="layui-badge layui-bg-red">已拒绝</span>';
    {{#   } }}
</script>
<!-- 数据操作工具条模板 -->
<script type="text/html" id="toolbar">
    {{# if(d.status == 0){ }}
        <a class="layui-btn layui-btn-sm layui-btn-danger" 
           data-confirm="确定通过吗?" 
           data-action="{:url('pass') }" 
           data-value="id#{{ d.id }}">通过</a>
        
        <a data-title="拒绝" 
           class="layui-btn layui-btn-sm layui-btn-warm" 
           data-modal="{:url('reject')}?id={{ d.id }}">拒绝</a>
    {{# } }}
</script>
{/block}